<?php
if (is_string($data_to_encode))
{
    // Generate Barcode data
    $barcode->barcode();
    $barcode->setType('C39');
    $barcode->setCode($data_to_encode);
    $barcode->setSize(40,0);

    // Generate filename
    $file = IMAGES . 'barcode/code_'.$data_to_encode.'.png';

    // Generates image file on server
    $barcode->writeBarcodeFile($file);

    // Display image
    echo $html->image('barcode/code_'.$data_to_encode.'.png');
}
?>